<template>
  <el-dialog title="调查问卷管理" :close-on-click-modal="false" :visible.sync="visible" fullscreen center append-to-body>
    <el-button class="miui-dialog-close-btn" @click="visible = false">关闭页面</el-button>
    <el-tabs type="border-card" v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="问卷记录查询" name="first">
        <resord v-if="firstVisible" ref="firstDialog"></resord>
      </el-tab-pane>
      <el-tab-pane label="问卷模板" name="second">
        <question-template v-if="secondVisible" ref="secondDialog"></question-template>
      </el-tab-pane>
    </el-tabs>
  </el-dialog>
</template>

<script>
  import Resord from './record'
  import QuestionTemplate from './template'

  export default {
    data(){
      return {
        visible: false,
        firstVisible: false,
        secondVisible: false,
        activeName: 'first'
      }
    },
    components: {
      Resord,
      QuestionTemplate
    },
    methods:{
      init(){
        this.visible = true
        this.firstVisible = true
        this.$nextTick(() => {

          this.$refs['firstDialog'].init()
        })
      },
      handleClick(tabName){
        this[tabName.name + 'Visible'] = true
        this.$nextTick(() => {
          this.$refs[tabName.name + 'Dialog'].init()
        })
      }
    }
  }
</script>

<style>
</style>
